package com.ujiuye.dao;

import com.ujiuye.util.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ColumnListHandler;

import java.sql.SQLException;
import java.util.List;

public class SearchDao {
    public List<String> getList(String name) {
        QueryRunner qr = new QueryRunner(DruidUtils.getDataSource());
        String sql = "select sname from student where sname like ? ";
        System.out.println("sql = " + sql);
        List<String> list = null;
        try {
            list = qr.query(sql, new ColumnListHandler<String>(),"%" + name + "%");
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return list;
    }
}
